//
//  AIMyLibraryBottomCell.m
//  HNBaseProject
//
//  Created by xujie on 2024/9/16.
//

#import "AIMyLibraryBottomCell.h"
#import "AIMyLibraryBottomShowCell.h"
@implementation AIMyLibraryBottomCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}

- (void)createUI {
    
    self.bgV = [[UIView alloc] initWithFrame:CGRectMake(15, 0, kScreenW - 30, 114.5)];
    [self.contentView addSubview:self.bgV];
    self.bgV.backgroundColor = [UIColor whiteColor];
    self.bgV.layer.cornerRadius = 15;
    self.bgV.layer.masksToBounds = YES;
    
    self.titleArray = @[NSLocalizedString(@"充值记录", nil),NSLocalizedString(@"消费记录", nil),NSLocalizedString(@"联系我们", nil)];
    self.imageArray = @[@"myProduction_recharge_record",@"myProduction_expense_calendar",@"myProduction_ contact"];
    
    [self.bgV addSubview:self.listCV];
    [self.listCV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.offset(0);
    }];
    
}

- (UICollectionView *)listCV {
   if (!_listCV) {
       UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc]init];
       layout.itemSize = CGSizeMake((kScreenW - 30) / 4.0, 114.5);
       layout.minimumLineSpacing = 0;//纵向间距(参考scrollDirection)
       layout.minimumInteritemSpacing = 0;//横向间距
       layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
       _listCV = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
       _listCV.backgroundColor = [UIColor clearColor];
       _listCV.delegate = self;
       _listCV.dataSource = self;
       _listCV.showsVerticalScrollIndicator = NO;
       _listCV.showsHorizontalScrollIndicator = NO;
       [_listCV registerClass:[AIMyLibraryBottomShowCell class] forCellWithReuseIdentifier:@"AIMyLibraryBottomShowCell"];
       
       }
    return _listCV;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

    return 3;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    AIMyLibraryBottomShowCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AIMyLibraryBottomShowCell" forIndexPath:indexPath];
    [cell reloadCellWithImage:self.imageArray[indexPath.item] title:self.titleArray[indexPath.item]];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    if (self.cellClick) {
        self.cellClick(indexPath.item);
    }
}

@end
